<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return=array();
	//查询会员信息
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	
	//查询车主信息
	$chezhu=pdo_get('jy_move_member',array('id'=>$_SESSION['uid']));
	//已有挪车卡数量
	$chezhu['num']=pdo_count('jy_move_card',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$return['chezhu']=$chezhu;
	$return['member']=$member;
	exi($return);
	
}
if($_RQ['op']=='set'){
	$return=array();
	if($_RQ['postdata']){
		$postdata=get_postdata();
		//exi($postdata['notice_type1'],'error');
		$notice_type=array();
		if($postdata['notice_type1']==true){
			array_push($notice_type,"1");
		}
		if($postdata['notice_type2']==true){
			array_push($notice_type,"2");
		}
		if($postdata['notice_type3']==true){
			array_push($notice_type,"3");
		}
		if($postdata['notice_type4']==true){
			array_push($notice_type,"4");
		}
		$data=array(
				'notice_type'=>json_encode($notice_type),
				'name'=>$postdata['name'],
				'mobile'=>$postdata['mobile'],
				'show_n'=>'0',
				'show_m'=>'0',
				'show_e'=>'0',
				'ewm'=>$postdata['ewm'],
				);
		if($postdata['show_n']==true){
			$data['show_n']=1;
		}
		if($postdata['show_m']==true){
			$data['show_m']=1;
		}
		if($postdata['show_e']==true){
			$data['show_e']=1;
		}
		$member_id=pdo_getcolumn('jy_move_member',array('id'=>$_SESSION['uid']),'id');		
		if($member_id){
			pdo_update('jy_move_member',$data,array('id'=>$member_id));
			exi('修改成功','','jy_move/home/');		 
		}
		else{
			$data['id']=$_SESSION['uid'];
			$data['uniacid']=$_SESSION['uniacid'];
			$data['createtime']=TIMESTAMP;
			pdo_insert('jy_move_member',$data);
			exi('设置成功','','jy_move/home/');
		}
	}
	//获得车主信息
    $member=pdo_get('jy_move_member',array('id'=>$_SESSION['uid']));
	if($member['show_n']=='1'){
		$member['show_n']=true;
	}
    else{
		$member['show_n']=false;
	}
	if($member['show_m']=='1'){
		$member['show_m']=true;
	}
    else{
		$member['show_m']=false;
	}
	if($member['show_e']=='1'){
		$member['show_e']=true;
	}
    else{
		$member['show_e']=false;
	}
	//通知方式
	if($member['notice_type']){
		$notice_type=json_decode($member['notice_type'],true);
		$member['notice_type1']=in_array('1',$notice_type)?true:false;
		$member['notice_type2']=in_array('2',$notice_type)?true:false;
		$member['notice_type3']=in_array('3',$notice_type)?true:false;
		$member['notice_type4']=in_array('4',$notice_type)?true:false;
	}
	else{
		$member['notice_type1']=false;
		$member['notice_type2']=false;
		$member['notice_type3']=false;
		$member['notice_type4']=false;
	}
	//获得系统设置的通知方式notice_type
	$basic=$this->plugin_setting('basic');
	$send_type=explode(";",$basic['send_type']);
	
	$return['show1']=in_array('1',$send_type)?true:false;
	$return['show2']=in_array('2',$send_type)?true:false;
	$return['show3']=in_array('3',$send_type)?true:false;
	$return['show4']=in_array('4',$send_type)?true:false;
	$return['item']=$member;
	$return['send_type']=$send_type;
	exi($return);
	}
	
		
?>